import * as req from '@/request';


export async function all() {
  return await req.get<API.TicketTypeList>('/tickettype/all');
}

export async function list(
  params: { [key: string]: any },
  sorter?: { [key: string]: any },
  filter?: { [key: string]: any },
) {
  return req.postForm<API.TicketTypeList>(
    '/tickettype/list',
    params,
    sorter,
    filter,
  );
}

export async function treeSelect() {
  return req.get<API.TicketTypeTreeSelect>('/tickettype/all');
}

export async function loadTicketTypeTrees() {
  const result = await treeSelect();

  if (result.success && result.data) {
    return Promise.resolve(result.data);
  }
  return Promise.resolve([]);
}

export async function add(data: { [key: string]: any }) {
  return req.postForm<API.Result>('/tickettype/create', data);
}

export async function update(data: { [key: string]: any }) {
  return req.postForm<API.Result>('/tickettype/update', data);
}

export async function remove(data: { key: number }) {
  return req.post<API.Result>('/tickettype/delete', data);
}

